Imports System.Windows.Forms
Imports dao
 Imports System.Data
Imports DTO
Public Class HOCSINHBus
Inherits AbstractBus
 Public Sub New()
 End Sub
 Public Sub New(ByVal ConnectionString As KetNoiDto)
 ketnoi = ConnectionString
 End Sub
 #Region "Xử Lý" 
 Public Sub Them(ByVal Dto As HOCSINHDto)
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.Them(Dto)
 End Sub
 Public Sub Xoa( ByVal IDHOCSINH As System.Int32)
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.xoa(IDHOCSINH)
 End Sub
 Public Sub sua(ByVal Dto As HOCSINHDto)
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.sua(Dto)
 End Sub
 #End Region 
 Public Function LayBangTable() As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 dao.laybang()
 Return Dao
 End Function
 Public Function LayBangTableIlist() As IList
 Dim Dao As New HOCSINHDao(ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoHOCSINH As HOCSINHdto = LayBangDTo(i, Dao) 
 aList.Add(dtoHOCSINH)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableSQL(ByVal sql As string) As DataTable
 Dim Dao As New  AbstractDao(sql,sql,ketnoi)
 Return Dao
 End Function
 Public Sub suaMAHOCSINH( ByVal MAHOCSINH as System.String, ByVal IDHOCSINH As System.Int32 )
 Dim dao As New HOCSINHDao(ketnoi)
 dao.suaMAHOCSINH(MAHOCSINH,IDHOCSINH)
 End Sub 
 Public Sub suaIDPHUHUYNH( ByVal IDPHUHUYNH as System.Int32, ByVal IDHOCSINH As System.Int32 )
 Dim dao As New HOCSINHDao(ketnoi)
 dao.suaIDPHUHUYNH(IDPHUHUYNH,IDHOCSINH)
 End Sub 
 Public Sub suaTENHOCSINH( ByVal TENHOCSINH as System.String, ByVal IDHOCSINH As System.Int32 )
 Dim dao As New HOCSINHDao(ketnoi)
 dao.suaTENHOCSINH(TENHOCSINH,IDHOCSINH)
 End Sub 
 Public Sub suaNGAYSINH( ByVal NGAYSINH as System.DateTime, ByVal IDHOCSINH As System.Int32 )
 Dim dao As New HOCSINHDao(ketnoi)
 dao.suaNGAYSINH(NGAYSINH,IDHOCSINH)
 End Sub 
 Public Sub suaGIOITINH( ByVal GIOITINH as System.Int32, ByVal IDHOCSINH As System.Int32 )
 Dim dao As New HOCSINHDao(ketnoi)
 dao.suaGIOITINH(GIOITINH,IDHOCSINH)
 End Sub 
 Public Sub suaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDHOCSINH As System.Int32 )
 Dim dao As New HOCSINHDao(ketnoi)
 dao.suaTRANGTHAI(TRANGTHAI,IDHOCSINH)
 End Sub 
 Public Sub suaGHICHU( ByVal GHICHU as System.String, ByVal IDHOCSINH As System.Int32 )
 Dim dao As New HOCSINHDao(ketnoi)
 dao.suaGHICHU(GHICHU,IDHOCSINH)
 End Sub 
 Public Function LayBangTable( ByVal IDHOCSINH As System.Int32) As DataTable
 Dim Dao As New HOCSINHDao(IDHOCSINH,ketnoi)
 Return Dao
 End Function
 Public Function LayBangTableIlist( ByVal IDHOCSINH As System.Int32) As IList
 Dim Dao As New HOCSINHDao(IDHOCSINH,ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoHOCSINH As HOCSINHdto = LayBangDTo(i, Dao) 
 aList.Add(dtoHOCSINH)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableTheoIDHOCSINH (ByVal IDHOCSINH As System.Int32) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoIDHOCSINH(IDHOCSINH)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDHOCSINH (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoIDHOCSINH(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDHOCSINH (ByVal IDHOCSINH As System.Int32) 
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.XOABangTheoIDHOCSINH(IDHOCSINH)
 End sub
 Public Function LayBangTableTheoMAHOCSINH (ByVal MAHOCSINH As System.String) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoMAHOCSINH(MAHOCSINH)
 Return Dao
 End Function
 Public Function LayBangTableTheoMAHOCSINH_like (ByVal MAHOCSINH As System.String ) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoMAHOCSINH_like (MAHOCSINH)
 Return Dao
 End Function
 Public Function LayBangTableTheoMAHOCSINH (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoMAHOCSINH(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoMAHOCSINH (ByVal MAHOCSINH As System.String) 
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.XOABangTheoMAHOCSINH(MAHOCSINH)
 End sub
 Public Function LayBangTableTheoIDPHUHUYNH (ByVal IDPHUHUYNH As System.Int32) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoIDPHUHUYNH(IDPHUHUYNH)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDPHUHUYNH (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoIDPHUHUYNH(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDPHUHUYNH (ByVal IDPHUHUYNH As System.Int32) 
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.XOABangTheoIDPHUHUYNH(IDPHUHUYNH)
 End sub
 Public Function LayBangTableTheoTENHOCSINH (ByVal TENHOCSINH As System.String) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoTENHOCSINH(TENHOCSINH)
 Return Dao
 End Function
 Public Function LayBangTableTheoTENHOCSINH_like (ByVal TENHOCSINH As System.String ) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoTENHOCSINH_like (TENHOCSINH)
 Return Dao
 End Function
 Public Function LayBangTableTheoTENHOCSINH (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoTENHOCSINH(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTENHOCSINH (ByVal TENHOCSINH As System.String) 
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.XOABangTheoTENHOCSINH(TENHOCSINH)
 End sub
 Public Function LayBangTableTheoNGAYSINH (ByVal NGAYSINH As System.DateTime) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoNGAYSINH(NGAYSINH)
 Return Dao
 End Function
 Public Function LayBangTableTheoNGAYSINH(ByVal NGAYSINH1 As System.DateTime,ByVal NGAYSINH2 As System.DateTime ) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoNGAYSINH(NGAYSINH1 ,NGAYSINH2)
 Return Dao
 End Function
 Public Function LayBangTableTheoNGAYSINH (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoNGAYSINH(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoNGAYSINH (ByVal NGAYSINH As System.DateTime) 
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.XOABangTheoNGAYSINH(NGAYSINH)
 End sub
 Public Function LayBangTableTheoGIOITINH (ByVal GIOITINH As System.Int32) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoGIOITINH(GIOITINH)
 Return Dao
 End Function
 Public Function LayBangTableTheoGIOITINH (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoGIOITINH(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoGIOITINH (ByVal GIOITINH As System.Int32) 
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.XOABangTheoGIOITINH(GIOITINH)
 End sub
 Public Function LayBangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(TRANGTHAI)
 Return Dao
 End Function
 Public Function LayBangTableTheoTRANGTHAI (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) 
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.XOABangTheoTRANGTHAI(TRANGTHAI)
 End sub
 Public Function LayBangTableTheoGHICHU (ByVal GHICHU As System.String) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoGHICHU(GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU_like (ByVal GHICHU As System.String ) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoGHICHU_like (GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangTheoGHICHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoGHICHU (ByVal GHICHU As System.String) 
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.XOABangTheoGHICHU(GHICHU)
 End sub
 Public Function LayBangDTo( ByVal IDHOCSINH As System.Int32) As HOCSINHdto
 Dim Dao As New HOCSINHDao(IDHOCSINH, ketnoi)
 Dim dto As New HOCSINHdto
 If Dao.Rows.Count<= 0 then Return dto
 Try
 If IsDBNull(Dao.Rows(0)("IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(0)("IDHOCSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("HOCSINH.IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(0)("HOCSINH.IDHOCSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("MAHOCSINH")) = False Then
 Dto.MAHOCSINH = Dao.Rows(0)("MAHOCSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("HOCSINH.MAHOCSINH")) = False Then
 Dto.MAHOCSINH = Dao.Rows(0)("HOCSINH.MAHOCSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("IDPHUHUYNH")) = False Then
 Dto.IDPHUHUYNH = Dao.Rows(0)("IDPHUHUYNH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("HOCSINH.IDPHUHUYNH")) = False Then
 Dto.IDPHUHUYNH = Dao.Rows(0)("HOCSINH.IDPHUHUYNH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TENHOCSINH")) = False Then
 Dto.TENHOCSINH = Dao.Rows(0)("TENHOCSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("HOCSINH.TENHOCSINH")) = False Then
 Dto.TENHOCSINH = Dao.Rows(0)("HOCSINH.TENHOCSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("NGAYSINH")) = False Then
 Dto.NGAYSINH = Dao.Rows(0)("NGAYSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("HOCSINH.NGAYSINH")) = False Then
 Dto.NGAYSINH = Dao.Rows(0)("HOCSINH.NGAYSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("GIOITINH")) = False Then
 Dto.GIOITINH = Dao.Rows(0)("GIOITINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("HOCSINH.GIOITINH")) = False Then
 Dto.GIOITINH = Dao.Rows(0)("HOCSINH.GIOITINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("HOCSINH.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("HOCSINH.TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("GHICHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("HOCSINH.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("HOCSINH.GHICHU")
 End if
Catch ex As Exception
End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal i As Integer, ByVal dao As DataTable) As HOCSINHdto
 Dim dto As New HOCSINHdto
 If Dao.Rows.Count<=0 then Return dto
 Try
 If IsDBNull(Dao.Rows(i)("IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(i)("IDHOCSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("HOCSINH.IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(i)("HOCSINH.IDHOCSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("MAHOCSINH")) = False Then
 Dto.MAHOCSINH = Dao.Rows(i)("MAHOCSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("HOCSINH.MAHOCSINH")) = False Then
 Dto.MAHOCSINH = Dao.Rows(i)("HOCSINH.MAHOCSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("IDPHUHUYNH")) = False Then
 Dto.IDPHUHUYNH = Dao.Rows(i)("IDPHUHUYNH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("HOCSINH.IDPHUHUYNH")) = False Then
 Dto.IDPHUHUYNH = Dao.Rows(i)("HOCSINH.IDPHUHUYNH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TENHOCSINH")) = False Then
 Dto.TENHOCSINH = Dao.Rows(i)("TENHOCSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("HOCSINH.TENHOCSINH")) = False Then
 Dto.TENHOCSINH = Dao.Rows(i)("HOCSINH.TENHOCSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("NGAYSINH")) = False Then
 Dto.NGAYSINH = Dao.Rows(i)("NGAYSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("HOCSINH.NGAYSINH")) = False Then
 Dto.NGAYSINH = Dao.Rows(i)("HOCSINH.NGAYSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("GIOITINH")) = False Then
 Dto.GIOITINH = Dao.Rows(i)("GIOITINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("HOCSINH.GIOITINH")) = False Then
 Dto.GIOITINH = Dao.Rows(i)("HOCSINH.GIOITINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("HOCSINH.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("HOCSINH.TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("GHICHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("HOCSINH.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("HOCSINH.GHICHU")
 End if
 Catch ex As Exception
 End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal dong As Integer, ByVal dao As DataGridView) As HOCSINHdto
 Dim dto As New HOCSINHdto
 If dao.Rows.Count <= 0 Then Return dto
 For cot As Integer = 0 To dao.Columns.Count - 1
 Try
 Dto.HoTro(dao.Columns(cot).DataPropertyName, dao.Item(cot, dong).Value)
 Catch ex As Exception
 End Try
 Next
 Return Dto
 End Function
 Public Function layBangNhieuTable() as Datatable
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.layBangNhieuTable()
 Return Dao
 End Function
 Public Sub Taotable()
 Dim Dao As New HOCSINHDao(ketnoi)
 Dao.TaoTable()
 End Sub
 End Class

